@namespace SwashbucklerDiary.Rcl.Pages
@inherits ImportantComponentBase

<MCard Class="mb-5"
       Elevation="0"
       Rounded="@("lg")">
    <MList Class="py-0">
        <MListItem OnClick="() => showConfig = true">
            <MListItemIcon>
                <MIcon>
                    mdi:mdi-cog-sync-outline
                </MIcon>
            </MListItemIcon>

            <MListItemContent Style="flex-basis:50%;">
                <wc-auto-scroll-text>@(I18n.T("Config"))</wc-auto-scroll-text>
            </MListItemContent>

            <MListItemContent Class="ml-2" Style="flex-basis:50%;">
                <MListItemSubtitle>
                    <wc-auto-scroll-text class="justify-end">@ConfiguredText</wc-auto-scroll-text>
                </MListItemSubtitle>
            </MListItemContent>

            <MListItemAction>
                <MIcon>chevron_right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-5"></MDivider>

        <MListItem OnClick="OpenUploadDialog">
            <MListItemIcon>
                <MIcon>
                    mdi:mdi-cloud-arrow-up-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                <MListItemTitle>
                    <wc-auto-scroll-text>@(I18n.T("Upload"))</wc-auto-scroll-text>
                </MListItemTitle>
                <MListItemSubtitle Class="text-caption-xs-only">
                    <wc-auto-scroll-text>@(I18n.T("Save the zip file generated as a database file"))</wc-auto-scroll-text>
                </MListItemSubtitle>
            </MListItemContent>
            <MListItemAction>
                <MIcon>chevron_right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-5"></MDivider>

        <MListItem OnClick="OpenDownloadDialog">
            <MListItemIcon>
                <MIcon>
                    mdi:mdi-cloud-arrow-down-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                <MListItemTitle>
                    <wc-auto-scroll-text>@(I18n.T("Pull"))</wc-auto-scroll-text>
                </MListItemTitle>
                <MListItemSubtitle Class="text-caption-xs-only">
                    <wc-auto-scroll-text>@(I18n.T("Select the zip file containing the database files"))</wc-auto-scroll-text>
                </MListItemSubtitle>
            </MListItemContent>
            <MListItemAction>
                <MIcon>chevron_right</MIcon>
            </MListItemAction>
        </MListItem>
    </MList>
</MCard>

<MCard Elevation="0"
       Rounded="@("lg")">
    <MListItem>
        <MListItemIcon>
            <MIcon>
                draft
            </MIcon>
        </MListItemIcon>
        <MListItemContent>
            <wc-auto-scroll-text>@(I18n.T("Include media files"))</wc-auto-scroll-text>
        </MListItemContent>
        <MListItemAction>
            <SettingSwitch @bind-Value="includeDiaryResources"
                           SettingKey="@nameof(Setting.WebDAVCopyResources)">
            </SettingSwitch>
        </MListItemAction>
    </MListItem>
</MCard>

<WebDavConfigDialog @bind-Visible="showConfig"
                    Form="configModel"
                    OnOK="SaveWebDavConfig">
</WebDavConfigDialog>

<CustomMDialog @bind-MyValue="showUpload"
               ContentClass="rounded-lg"
               MaxWidth="420">
    <MCard>
        <MCardTitle Class="font-weight-bold flex-nowrap">
            <wc-auto-scroll-text>@(I18n.T("Upload"))</wc-auto-scroll-text>
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="@(()=>showUpload=false)">
                <MIcon>close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="pb-0">
            @(I18n.T("The data will be saved to an online folder") + webDavFolderName)
        </MCardText>
        <MCardActions>
            <MSpacer></MSpacer>
            <MButton Text="true"
                     OnClick="()=>showUpload=false">
                @(I18n.T("Cancel"))
            </MButton>
            <MButton Text="true"
                     Color="primary"
                     OnClick="Upload">
                @(I18n.T("OK"))
            </MButton>
        </MCardActions>
    </MCard>
</CustomMDialog>

<CustomMDialog @bind-MyValue="showDownload"
               ContentClass="rounded-lg"
               MaxWidth="420"
               Scrollable="true">
    <MCard>
        <MCardTitle Class="font-weight-bold flex-nowrap">
            <wc-auto-scroll-text>@(I18n.T("Pull"))</wc-auto-scroll-text>
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="()=>showDownload=false">
                <MIcon>close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="scroll-show pb-0 mb-5"
                   Style="max-height:300px;">
            <Virtualize Items="fileList"
                        ItemSize="56"
                        Context="item">
                <MListItem @key="item"
                           Class="mb-1 rounded"
                           OnClick="()=>Download(item)">
                    <MListItemContent>
                        <MListItemTitle>
                            <wc-auto-scroll-text>@item</wc-auto-scroll-text>
                        </MListItemTitle>
                    </MListItemContent>
                </MListItem>
            </Virtualize>
        </MCardText>
    </MCard>
</CustomMDialog>

